package com.mars.admin.modules.post.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.mars.admin.modules.base.entity.BaseEntity;
import com.mars.admin.framework.listener.EntityChangeListener;
import com.mybatisflex.annotation.*;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

/**
 * 圈子帖子实体类
 *
 * @author Mars
 * @version 1.0
 * @date 2025-01-07
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@Table(value = "tb_post", onInsert = EntityChangeListener.class, onUpdate = EntityChangeListener.class)
@Schema(description = "圈子帖子")
public class Post extends BaseEntity {

    private static final long serialVersionUID = 1L;

    /**
     * 帖子ID
     */
    @Id(keyType = KeyType.Auto)
    @Schema(description = "帖子ID", example = "1")
    private Long id;

    /**
     * 发布用户ID
     */
    @Schema(description = "发布用户ID", example = "1", requiredMode = Schema.RequiredMode.REQUIRED)
    @Column("user_id")
    private Long userId;

    /**
     * 帖子标题
     */
    @Schema(description = "帖子标题", example = "美丽的海滨风光")
    @Column("title")
    private String title;

    /**
     * 帖子内容
     */
    @Schema(description = "帖子内容", example = "今天去了海边，风景真的很美！", requiredMode = Schema.RequiredMode.REQUIRED)
    @Column("content")
    private String content;

    /**
     * 图片集合
     */
    @Schema(description = "图片集合", example = "[\"https://example.com/1.jpg\", \"https://example.com/2.jpg\"]")
    @Column("images")
    private String images;


    /**
     * 图片列表
     */
    @Column(ignore = true)
    private List<String> iamgesList;


    /**
     * 视频URL
     */
    @Schema(description = "视频URL", example = "https://example.com/video.mp4")
    @Column("video_url")
    private String videoUrl;

    /**
     * 视频封面
     */
    @Schema(description = "视频封面", example = "https://example.com/cover.jpg")
    @Column("video_cover")
    private String videoCover;

    /**
     * 位置信息
     */
    @Schema(description = "位置信息", example = "三亚海滨公园")
    @Column("location")
    private String location;

    /**
     * 详细地址
     */
    @Schema(description = "详细地址", example = "海南省三亚市海滨公园")
    @Column("address")
    private String address;

    /**
     * 纬度
     */
    @Schema(description = "纬度", example = "18.2533")
    @Column("latitude")
    private BigDecimal latitude;

    /**
     * 经度
     */
    @Schema(description = "经度", example = "109.5061")
    @Column("longitude")
    private BigDecimal longitude;

    /**
     * 地区ID
     */
    @Schema(description = "地区ID", example = "1")
    @Column("region_id")
    private Long regionId;

    /**
     * 关联话题ID集合
     */
    @Schema(description = "关联话题ID集合", example = "[1, 2, 3]")
    @Column("topics")
    private String topics;

    /**
     * 标签集合
     */
    @Schema(description = "标签集合", example = "[\"旅行\", \"海滨\", \"风景\"]")
    @Column("tags")
    private String tags;

    /**
     * 帖子类型
     */
    @Schema(description = "帖子类型：1-图文，2-视频，3-纯文字，4-链接分享", example = "1")
    @Column("post_type")
    private Integer postType;

    /**
     * 分享链接URL
     */
    @Schema(description = "分享链接URL", example = "https://example.com")
    @Column("link_url")
    private String linkUrl;

    /**
     * 链接标题
     */
    @Schema(description = "链接标题", example = "精彩文章标题")
    @Column("link_title")
    private String linkTitle;

    /**
     * 链接描述
     */
    @Schema(description = "链接描述", example = "这是一篇精彩的文章")
    @Column("link_description")
    private String linkDescription;

    /**
     * 链接缩略图
     */
    @Schema(description = "链接缩略图", example = "https://example.com/thumb.jpg")
    @Column("link_image")
    private String linkImage;

    /**
     * 是否原创
     */
    @Schema(description = "是否原创：0-转发，1-原创", example = "1")
    @Column("is_original")
    private Integer isOriginal;

    /**
     * 原帖ID
     */
    @Schema(description = "原帖ID（转发时）", example = "1")
    @Column("original_post_id")
    private Long originalPostId;

    /**
     * 浏览次数
     */
    @Schema(description = "浏览次数", example = "100")
    @Column("view_count")
    private Integer viewCount;

    /**
     * 点赞数
     */
    @Schema(description = "点赞数", example = "20")
    @Column("like_count")
    private Integer likeCount;

    /**
     * 评论数
     */
    @Schema(description = "评论数", example = "5")
    @Column("comment_count")
    private Integer commentCount;

    /**
     * 分享数
     */
    @Schema(description = "分享数", example = "3")
    @Column("share_count")
    private Integer shareCount;

    /**
     * 收藏数
     */
    @Schema(description = "收藏数", example = "8")
    @Column("collect_count")
    private Integer collectCount;

    /**
     * 是否置顶
     */
    @Schema(description = "是否置顶：0-否，1-是", example = "0")
    @Column("is_top")
    private Integer isTop;

    /**
     * 是否热门
     */
    @Schema(description = "是否热门：0-否，1-是", example = "0")
    @Column("is_hot")
    private Integer isHot;

    /**
     * 是否推荐
     */
    @Schema(description = "是否推荐：0-否，1-是", example = "0")
    @Column("is_recommend")
    private Integer isRecommend;

    /**
     * 可见性
     */
    @Schema(description = "可见性：1-公开，2-仅关注者，3-私密", example = "1")
    @Column("visibility")
    private Integer visibility;

    /**
     * 允许评论
     */
    @Schema(description = "允许评论：0-不允许，1-允许", example = "1")
    @Column("allow_comment")
    private Integer allowComment;

    /**
     * 状态
     */
    @Schema(description = "状态：0-草稿，1-已发布，2-已删除，3-审核中，4-审核拒绝", example = "1")
    @Column("status")
    private Integer status;

    /**
     * 审核状态
     */
    @Schema(description = "审核状态：0-待审核，1-审核通过，2-审核拒绝", example = "1")
    @Column("audit_status")
    private Integer auditStatus;

    /**
     * 审核原因
     */
    @Schema(description = "审核原因", example = "内容违规")
    @Column("audit_reason")
    private String auditReason;

    /**
     * 审核时间
     */
    @Schema(description = "审核时间", example = "2024-01-01 12:00:00")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Column("audit_time")
    private LocalDateTime auditTime;

    /**
     * 审核人ID
     */
    @Schema(description = "审核人ID", example = "1")
    @Column("audit_user_id")
    private Long auditUserId;
}
